package com.example.administrator.managesystem.video;

import android.content.Context;
import android.util.Log;

import com.example.administrator.managesystem.bean.HiKTokenBean;
import com.example.administrator.managesystem.bean.TagBean;
import com.example.administrator.managesystem.network.GuideAPI;
import com.example.administrator.managesystem.network.ServiceManager;
import com.example.administrator.managesystem.ui.VideoPlayView;
import com.example.administrator.managesystem.utils.ToastUtils;

import java.io.IOException;

import okhttp3.ResponseBody;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class VideoPlayPresenter {
   private VideoPlayView videoPlayView;

    public VideoPlayPresenter(VideoPlayView videoPlayView) {
        this.videoPlayView = videoPlayView;
    }

    public void showHikToken(final Context context,String user_id,String token){
        ServiceManager.getInstance(context).getService(GuideAPI.class).getToken(user_id,token)
                .subscribeOn(Schedulers.io())//IO线程加载数据
                .observeOn(AndroidSchedulers.mainThread())//主线程显示数据
                .subscribe(new Subscriber<HiKTokenBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable t) {
                        ToastUtils.showToast(context,t.getMessage());
                    }

                    @Override
                    public void onNext(HiKTokenBean hiKTokenBean) {
                    if(hiKTokenBean.getStatus()==200){
                        videoPlayView.showToken(hiKTokenBean.getData());
                    }
                    }

                });


    }
}
